﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Linq.Mapping;
using ECI.Entities;
using ECI.Entities.Builder;

namespace ECI.LIP.Entities
{
    ///<summary>
    ///[SYS_USER]
    ///</summary>
    [Serializable]
    [Table(Name = "SYS_USER")]
    public partial class SysUser
    {
        ///<summary>
        ///[用户ID]
        ///</summary>
        [Column(Storage = "USER_ID")]
        public string UserId { get { return this._UserId; } set { this._UserId = value; if (this.DataModelBegin)AddEnum(SysUserEnum.UserId); } }
        ///<summary>
        ///[用户名]
        ///</summary>
        [Column(Storage = "USER_NAME")]
        public string UserName { get { return this._UserName; } set { this._UserName = value; if (this.DataModelBegin)AddEnum(SysUserEnum.UserName); } }
        ///<summary>
        ///[登陆名]
        ///</summary>
        [Column(Storage = "LOGIN_NO")]
        public string LoginNo { get { return this._LoginNo; } set { this._LoginNo = value; if (this.DataModelBegin)AddEnum(SysUserEnum.LoginNo); } }
        ///<summary>
        ///[登陆密码]
        ///</summary>
        [Column(Storage = "LOGIN_PWD")]
        public string LoginPwd { get { return this._LoginPwd; } set { this._LoginPwd = value; if (this.DataModelBegin)AddEnum(SysUserEnum.LoginPwd); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "EMAIL")]
        public string Email { get { return this._Email; } set { this._Email = value; if (this.DataModelBegin)AddEnum(SysUserEnum.Email); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "SENDMAIL")]
        public string Sendmail { get { return this._Sendmail; } set { this._Sendmail = value; if (this.DataModelBegin)AddEnum(SysUserEnum.Sendmail); } }
        ///<summary>
        ///[]
        ///</summary>
        [Column(Storage = "LAST_LOGIN_TIME")]
        public System.Nullable<System.DateTime> LastLoginTime { get { return this._LastLoginTime; } set { this._LastLoginTime = value; if (this.DataModelBegin)AddEnum(SysUserEnum.LastLoginTime); } }
        ///<summary>
        ///[状态]
        ///</summary>
        [Column(Storage = "STATUS")]
        public string Status { get { return this._Status; } set { this._Status = value; if (this.DataModelBegin)AddEnum(SysUserEnum.Status); } }

        /// <summary>
        /// ????????:???????True?,????????,?????????????????????,???????????????????????????????????
        /// </summary>
        public void StartSetSQLValue()
        {
            this.DataModelBegin = true;
        }

        /// <summary>
        /// ???????
        /// </summary>
        public void EndSetSQLValue()
        {
            this.DataModelBegin = false;
        }

        private bool DataModelBegin;
        public List<SysUserEnum> ListEnum { get; set; }

        public void AddEnum(SysUserEnum item)
        {
            if (ListEnum == null) ListEnum = new List<SysUserEnum>();
            if (!ListEnum.Contains(item))
            {
                ListEnum.Add(item);
            }
        }



        private SysUserEnum _keyField;
        public SysUserEnum KeyField { get { return this._keyField; } }

        public void SetKeyField(SysUserEnum keyField)
        {
            this.HasSetKeyField = true;
            this._keyField = keyField;
        }

        public SysUser()
        {
        }

        public SysUser(SysUserEnum keyField)
        {
            this.HasSetKeyField = true;
            this._keyField = keyField;
        }

        public bool HasSetKeyField { get; set; }

        public SysUserEnum SortByField { get; set; }

        public SortDirection SortDirection { get; set; }


        public string SQLUpdate
        {
            get { return new SQLBuilder<SysUser, SysUserEnum>().Update(this); }
        }

        public string SQLInsert
        {
            get { return new SQLBuilder<SysUser, SysUserEnum>().Insert(this); }
        }

        public string SQLDelete
        {
            get { return new SQLBuilder<SysUser, SysUserEnum>().Delete(this); }
        }

        public string SQLSelect
        {
            get { return new SQLBuilder<SysUser, SysUserEnum>().Select(this); }
        }

        public void SetAllEnum()
        {
            new SQLBuilder<SysUser, SysUserEnum>().SetAllEnum(this);
        }

        private DataTable FetchDataTable()
        {
            return FetchDataTable(null);
        }

        private DataTable FetchDataTable(object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysUser, SysUserEnum>().GetDataTable(this, ts);
        }

        /// <summary>
        /// ???????????????????FetchEntity??????
        /// </summary>
        public bool HasFetchData { get; set; }

        /// <summary>
        /// ??????????????????????FetchEntity??????
        /// </summary>
        public bool NotFetchData { get { return !HasFetchData; } }

        /// <summary>
        /// ??????-???????SQL
        /// </summary>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysUser FetchEntity()
        {
            return FetchEntity("", null);
        }

        /// <summary>
        /// ??????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysUser FetchEntity(string sql)
        {
            return FetchEntity(sql, null);
        }

        /// <summary>
        /// ??????-???????SQL
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysUser FetchEntity(object ts)
        {
            return FetchEntity("", ts);
        }

        /// <summary>
        /// ??????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <param name="ts">????</param>
        /// <returns>???:???????????????????????? ??????????????HasFetchData??????</returns>
        public SysUser FetchEntity(string sql, object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysUser, SysUserEnum>().GetEntity(sql, this, ts);
        }

        /// <summary>
        /// ?????????-???????SQL
        /// </summary>
        /// <returns>??????</returns>
        public List<SysUser> FetchEntities()
        {
            return FetchEntities("", null);
        }

        /// <summary>
        ///  ?????????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <returns>??????</returns>		
        public List<SysUser> FetchEntities(string sql)
        {
            return FetchEntities(sql, null);
        }

        /// <summary>
        /// ?????????-???????SQL
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>??????</returns>
        public List<SysUser> FetchEntities(object ts)
        {
            return FetchEntities("", ts);
        }

        /// <summary>
        ///  ?????????-???SQL???
        /// </summary>
        /// <param name="sql">??????</param>
        /// <param name="ts">????</param>
        /// <returns>??????</returns>
        public List<SysUser> FetchEntities(string sql, object ts)
        {
            return new ECI.Entities.Builder.EntityBuilder<SysUser, SysUserEnum>().GetEntities(sql, this, ts);
        }

        /// <summary>
        /// ?????????????
        /// </summary>
        /// <returns>True???? False??????</returns>
        public bool Exists()
        {
            return Exists(null);
        }

        /// <summary>
        ///  ?????????????
        /// </summary>
        /// <param name="ts">????</param>
        /// <returns>True???? False??????</returns>
        public bool Exists(object ts)
        {
            SysUser item = this.FetchEntity(ts);
            return item.HasFetchData;
        }




    }


    public partial class SysUser
    {
        private string _UserId = "";
        private string _UserName = "";
        private string _LoginNo = "";
        private string _LoginPwd = "";
        private string _Email = "";
        private string _Sendmail = "";
        private System.Nullable<System.DateTime> _LastLoginTime;
        private string _Status = "";
    }


    public enum SysUserEnum
    {
        ///<summary>
        ///[用户ID]
        ///</summary>
        UserId,
        ///<summary>
        ///[用户名]
        ///</summary>
        UserName,
        ///<summary>
        ///[登陆名]
        ///</summary>
        LoginNo,
        ///<summary>
        ///[登陆密码]
        ///</summary>
        LoginPwd,
        ///<summary>
        ///[]
        ///</summary>
        Email,
        ///<summary>
        ///[]
        ///</summary>
        Sendmail,
        ///<summary>
        ///[]
        ///</summary>
        LastLoginTime,
        ///<summary>
        ///[状态]
        ///</summary>
        Status
    }
}
